﻿Public Class frmServer

    Private _sqlConn As New SqlClient.SqlConnectionStringBuilder
    Public Property ConnectionString As String
        Get
            Return _sqlConn.ConnectionString
        End Get
        Set(value As String)
            _sqlConn.ConnectionString = value
        End Set
    End Property

    Private Sub frmTambahServer_HelpButtonClicked(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.HelpButtonClicked
        MsgBox("Untuk cara mengisi form ini, silahkan baca petunjuk.", vbInformation)
        e.Cancel = True
    End Sub

    Private Sub frmTambahServer_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        PropertyGrid1.SelectedObject = _sqlConn
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If String.IsNullOrWhiteSpace(_sqlConn.DataSource) Then
            MsgBox("Server belum di isi!", vbExclamation, "Data belum lengkap")
            Return
        End If

        If String.IsNullOrWhiteSpace(_sqlConn.InitialCatalog) Then
            MsgBox("Database belum di isi!", vbExclamation, "Data belum lengkap")
            Return
        End If

        Dim lanjut As Boolean = False
        If _sqlConn.IntegratedSecurity Then
            lanjut = True
        Else
            lanjut = Not (String.IsNullOrWhiteSpace(_sqlConn.UserID) OrElse String.IsNullOrWhiteSpace(_sqlConn.Password))
        End If
        If Not lanjut Then
            MsgBox("UserID atau Password belum di isi.", vbExclamation, "Data belum lengkap")
            Return
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub frmServer_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown
        PropertyGrid1.Refresh()
    End Sub
End Class